#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   1.csv.py
@Contact :   fengfeng.qiu@amh-group.com

@Modify Time      @Author    
------------      -------    
2022/9/14 10:13   qiufengfeng      
'''
import pandas as pd
filename = "3.csv"

df = pd.read_csv(filename)
def cacl_price_result(item):
    biaozhu_shipper_price = item['biaozhu_shipper_price']
    old_shipper_price = item["old_shipper_price"]
    new_shipper_price = item["shipper_target_price"]


    biaozhu_driver_price = item['biaozhu_driver_price']
    old_driver_price = item['old_driver_price']
    new_dirver_price = item['driver_target_price']

    true_shipper_label  = -1
    old_shipper_label = -1
    new_shipper_label = -1

    true_driver_label = -1
    old_driver_label = -1
    new_driver_label = -1

    if biaozhu_shipper_price != 0 :
        true_shipper_label = 1

        if old_shipper_price == 0:
            old_shipper_label = -1
        else:
            if biaozhu_shipper_price == old_shipper_price:
                old_shipper_label = 1
            else:
                old_shipper_label = 0

        if new_shipper_price == 0:
            new_shipper_label = -1
        else:
            if new_shipper_price == biaozhu_shipper_price:
                new_shipper_label = 1
            else:
                new_shipper_label = 0


    if biaozhu_driver_price != 0 :
        true_driver_label = 1

        if old_driver_price == 0:
            old_driver_label = -1
        else:
            if biaozhu_driver_price == old_driver_price:
                old_driver_label = 1
            else:
                old_driver_label = 0

        if new_dirver_price == 0:
            new_driver_label = -1
        else:
            if biaozhu_driver_price == new_dirver_price:
                new_driver_label = 1
            else:
                new_driver_label = 0



    return true_shipper_label  , old_shipper_label , new_shipper_label,true_driver_label , old_driver_label ,new_driver_label

df["true_shipper_label"],df["old_shipper_label"],df["new_shipper_label"],df["true_driver_label"] ,df["old_driver_label"] ,df["new_driver_label"] = zip(*df.apply(cacl_price_result,axis=1))
df

print(df["new_shipper_label"].value_counts())
print(df["old_shipper_label"].value_counts())
print(df["true_shipper_label"].value_counts())
print(df["new_driver_label"].value_counts())
print(df["old_driver_label"].value_counts())
print(df["true_driver_label"].value_counts())
